package cn.tedu._06interceptor.config;

import cn.tedu._06interceptor.interceptors.MyInterceptor1;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

//
// 策略1：注册拦截器:默认拦截所有请求;
        //registry.addInterceptor(new MyInterceptor1());


//         策略2：拦截指定的单个请求,比如只拦截登录请求;
        //registry.addInterceptor(new MyInterceptor1())
        //        .addPathPatterns("/v1/users/login");

//         策略3：拦截指定的多个请求,比如拦截登录、注册请求;
        //registry.addInterceptor(new MyInterceptor1())
        //        .addPathPatterns("/v1/users/login", "/v1/users/reg");



//        策略4：拦截制定的多个请求，比如拦截用户模块的所有请求，**表示任意路径
//        registry.addInterceptor(new MyInterceptor1())
//                .addPathPatterns("/v1/users/**");

//      策略5：排除指定的请求，比如拦截用户模块除了登录之外的所有请求
//        registry.addInterceptor(new MyInterceptor1())
//                .addPathPatterns("/v1/users/**")
//                .excludePathPatterns("/v1/users/login");

//        registry.addInterceptor(new MyInterceptor1());

//        registry.addInterceptor(new MyInterceptor1())
//                .addPathPatterns("/v1/weibo/**");

//        registry.addInterceptor(new MyInterceptor1())
//                .addPathPatterns("/v1/weibo/**")
//                .excludePathPatterns("/v1/weibo/login");
    }



}
